Option Public
Option Declare

Sub Initialize()
	'/**
	' * Web运行代理
	' * 
	' * @param 参数名 参数说明
	' * @return 返回类型 返回说明
	' * @depends
	' * @see
	' * @error
	' * @version 1.0
	' * @author
	' */
try:
	'set up error handler
	On Error GoTo catch
	
	'	重要环境、对象、变量定义
	Dim session As NotesSession
	Dim note As NotesDocument
	Dim dbCurrent As NotesDatabase
	Dim strQuery_string As String		'代理的url参数
	Dim strMainUnid As String		'传送的主文档unid
	
	
	'	重要环境、对象、变量赋值
	Set session = New NotesSession
	Set note = session.documentcontext
	Set dbCurrent = note.parentdatabase
	
	'	获取当前主文档
	strQuery_string = note.query_string_decoded(0)
	strMainUnid = getRefValue(strQuery_string,"unid=")
	
	GoTo finally
catch:
	'log error
	'Msgbox Erl & ":" & Error
	MsgBox LSI_Info(2) & " called by " & LSI_Info(12) & "(" & LSI_Info(430) & "): " & Error$ & " - Line: " & CStr(Erl)
	'resume to the final thing
	Resume finally
	
finally:
	'do the final thing
	
End Sub
Function getRefValue(Byval strURLParam As String,strTitle As String)As String
'『函数功能』
'	Domino的应用可利用URL来传递参数，本函数从URL中读取指定参数项的值
'『函数接口』
'	strURLParam	input	URL部分字符串，例如： ?openform&count=20&start=41
'	strTitle		input	指定要读取的参数项，例如：count=
'『函数返回值』
'	指定参数项的值	字符串	例如：20，如果找不到指定的参数项，则返回空字符串
	
	Dim strTemp As String
	Dim intPos1 As Integer,intPos2 As Integer
	
	On Error Goto errorHandle
	
	strTemp=strURLParam
	intPos1=Instr(strTemp,"&"+strTitle)+1
	If intPos1=1 Then
		getRefValue=""
		Exit Function
	End If
	strTemp=Right(strTemp,Len(strTemp)-intPos1-Len(strTitle)+1)
	intPos2=Instr(strTemp,"&")
	If(intPos2>0)Then
		strTemp=Left(strTemp,intPos2-1)
	End If
	getRefValue=strTemp
	
	Exit Function
errorHandle:
	MsgBox LSI_Info(2) & " called by " & LSI_Info(12) & "(" & LSI_Info(430) & "): " & Error$ & " - Line: " & CStr(Erl)
	Exit Function
End Function